package edu.uwm.cs552;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Stroke;

import edu.uwm.cs552.util.Pair;

public enum Barrier implements Topography<Barrier>{
	BERASE, BLOCK, INLET, RIVER, DRAWN;
	
	public static final Color INLET_COLOR = new Color(0xad, 0xd8, 0xe6);
	public static final Color RIVER_DRAWN_COLOR = new Color(0x0, 0x0, 0xff);
	
	
	

	@Override
	public HasTopography<Barrier> getOrigin() {
		return HexEdge.ORIGIN;
	}


	/* (non-Javadoc)
	 * @see edu.uwm.cs552.Topography#draw(java.awt.Graphics, edu.uwm.cs552.HexEdge, double)
	 */
	@Override
	public void draw(Graphics g, HasTopography<Barrier> h, double scale, boolean showHidden) {
		float thickness = 0;
		
		Graphics2D g2 = (Graphics2D)g; 
		Stroke savedStroke = g2.getStroke();
		
		switch(this) {
			case BLOCK: g.setColor(Color.BLACK); thickness = (float) (scale/5); break;
			case INLET: g.setColor(INLET_COLOR); thickness = (float) (scale/5); break;
			case RIVER: g.setColor(RIVER_DRAWN_COLOR); thickness = (float) (scale/10); break; 
			case DRAWN: g.setColor(RIVER_DRAWN_COLOR); thickness = (float) (scale/10); break;
		}
		
		g2.setStroke(new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
		if(this != BERASE) {
			Pair<Point, Point> pair = h.toLineSegment(scale);
			g.drawLine(((Point)pair.fst).x, ((Point)pair.fst).y, ((Point)pair.snd).x, ((Point)pair.snd).y);
		}
		g2.setStroke(savedStroke);
	}

}
